package com.nhim.cms.domain;
// default package

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Version;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * ContentTypeElementDefinition entity. @author Huy Lieu Ta
 */
@Entity
@Table(name = "nhim_content_type_element_definition", catalog = "nhim_cms")
public class ContentTypeElementDefinition implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer id;
	private ElementDefinition elementDefinition;
	private ContentType contentType;
	private String description;
	private Integer position;
	private Boolean isRequired = false;
	private Integer version;

	// Constructors

	/** default constructor */
	public ContentTypeElementDefinition() {
	}

	/** minimal constructor */
	public ContentTypeElementDefinition(ElementDefinition elementDefinition,
			ContentType contentType) {
		this.elementDefinition = elementDefinition;
		this.contentType = contentType;
	}

	/** full constructor */
	public ContentTypeElementDefinition(ElementDefinition elementDefinition,
			ContentType contentType, String description, Integer position,Boolean isRequired) {
		this.elementDefinition = elementDefinition;
		this.contentType = contentType;
		this.description = description;
		this.position = position;
		this.isRequired = isRequired;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "element_id", nullable = false)
	public ElementDefinition getElementDefinition() {
		return this.elementDefinition;
	}

	public void setElementDefinition(ElementDefinition elementDefinition) {
		this.elementDefinition = elementDefinition;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "content_type_id", nullable = false)
	public ContentType getContentType() {
		return this.contentType;
	}

	public void setContentType(ContentType contentType) {
		this.contentType = contentType;
	}

	@Column(name = "description", length = 200)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	@Column(name="is_required")
	public void setIsRequired(Boolean isRequired)
	{
		this.isRequired = isRequired;
		
	}
	public Boolean getIsRequired()
	{
		return isRequired;
		
	}

	@Column(name = "position")
	public Integer getPosition() {
		return this.position;
	}

	public void setPosition(Integer position) {
		this.position = position;
	}
	@Version
	@Column(name = "version")
	public Integer getVersion() {
		return this.version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

}